#!/bin/bash
#Program:
#	This program shows "Hello World!" in your screen.
#History:
#20171113	zhouxh	v1
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH

read -p "Please input a directory:" dir
if [ "${dir}" == "" -o ! -d "${dir}" ]; then
	echo "The ${dir} is NOT exist in your system."
	exit 1
fi

filelist=$(ls ${dir})		# 列出所有在该目录下的文件名称
for filename in ${filelist}
do
	perm=""
	test -r "${dir}/${filename}" && perm="${perm} readable "
	test -w "${dir}/${filename}" && perm="${perm} writable "
	test -x "${dir}/${filename}" && perm="${perm} executable "
	echo "The file  ${filename}'s  permission is  ${perm}"
done
